********************************************************************************
************************ HOUSE PRICE GROWTH RESULTS ****************************
********************************************************************************

use LTI_HP.dta, clear

* This data set combines four different samples / house price index
* Each sub-data set is labelled in the variable 'columns'
* They are not meant to be used together (period_a, for instance, is only coherent within sub-data set)

********** Table 10A

***** COLUMN 1: 25TH PERCENTILE WITH ALL TRANSACTIONS *****

preserve

keep if columns == "1" // semi-annual data using all transactions for the house price index

xtset lac period_s

*** Annual change in prices:
gen lp25 = log(price_p25)
gen c25 = lp25 - l2.lp25

*** Windsorising:
gen c25w = c25
sum c25, d
replace c25w = `r(p1)' if c25 < `r(p1)'
replace c25w = `r(p99)' if c25 > `r(p99)' & c25 != .

*** Generate time dummies:
gen policy = 0 // captures the post-policy period (2014Q3 - 2018Q2)
replace policy = 1 if period_s >= 9

gen brexit = 0 // captures the post-referendum period (2016Q3 - 2018Q2)
replace brexit = 1 if period_s >= 13

*** Generate fixed effects
egen region_time = group(region period_s)
egen region_time_const_FE = group(region_time dconstr)
egen region_time_lowinc_FE = group(region_time dlowinc)
egen county_time = group(county period_s)


*** REGRESSIONS
* c.1
reghdfe c25w /*
*/ c.brexit##c.dconstr##c.dlowinc /*
*/ c.policy##c.dconstr##c.dlowinc /*
*/ if period_s >= 5 & period_s <= 16, /*
*/ absorb(region_time_const_FE region_time_lowinc_FE county_time lac) vce(cluster lac)
outreg2 using "LTI_T10A.tex", keep(c.brexit#c.dconstr#c.dlowinc c.policy#c.dconstr#c.dlowinc) nocons dec(3) tex replace

restore

***** COLUMNS 2 AND 3: P25 / P75 WITH REPEAT POSTCODE-TYPE *****

preserve

keep if columns == "2&3" // annual data with repeat postcode-house type index

*** Annual change in prices:
xtset lac period_a

gen lp25 = log(price_p25)
bysort lac: gen c25 = lp25 - l.lp25

gen lp75 = log(price_p75)
bysort lac: gen c75 = lp75 - l.lp75

*** Windsorise:
foreach var of varlist c25 c75 {
gen `var'w = `var'
sum `var', d
replace `var'w = `r(p1)' if `var' < `r(p1)'
replace `var'w = `r(p99)' if `var' > `r(p99)' & `var' != .
}

*** Generate time dummies:
gen policy = 0 // captures the post-policy period (2014Q3 - 2018Q2)
replace policy = 1 if period_a >= 3

gen brexit = 0 // captures the post-referendum period (2016Q3 - 2018Q2)
replace brexit = 1 if period_a >= 5

*** Generate fixed effects:
egen region_time = group(region period_a)
egen region_time_const_FE = group(region_time dconstr)
egen region_time_lowinc_FE = group(region_time dlowinc)
egen county_time = group(county period_a)

*** Regressions

* c.2
reghdfe c25w /*
*/ c.brexit##c.dconstr##c.dlowinc /*
*/ c.policy##c.dconstr##c.dlowinc /*
*/ if period_a >= 1 & period_a <= 6, /*
*/ absorb(region_time_const_FE region_time_lowinc_FE county_time lac) vce(cluster lac)
outreg2 using "LTI_T10A.tex", keep(c.brexit#c.dconstr#c.dlowinc c.policy#c.dconstr#c.dlowinc) nocons dec(3) tex

* c.3
reghdfe c75w /*
*/ c.brexit##c.dconstr##c.dlowinc /*
*/ c.policy##c.dconstr##c.dlowinc /*
*/ if period_a >= 1 & period_a <= 6, /*
*/ absorb(region_time_const_FE region_time_lowinc_FE county_time lac) vce(cluster lac)
outreg2 using "LTI_T10A.tex", keep(c.brexit#c.dconstr#c.dlowinc c.policy#c.dconstr#c.dlowinc) nocons dec(3) tex

restore

***** COLUMNS 4 AND 5: BOTTOM AND TOP TERCILES WITH REPEAT POSTCODE-TYPE *****

preserve

keep if columns == "4&5" // annual data with repeat postcode-house type fixing pairs by initial price

gen log_price = log(price)

*** Annual change in prices
forvalues x = 1 / 3 {
sort lac perc period_a
bysort lac: gen ch_p_`x' = log_price - log_price[_n-1] if period_a == period_a[_n-1] + 1 & perc == `x' & perc[_n-1] == `x'
}

*** Windsorise
forvalues x = 1 / 3 {
gen chw_p_`x' = ch_p_`x'
sum ch_p_`x', d
replace chw_p_`x' = `r(p1)' if chw_p_`x' < `r(p1)'
replace chw_p_`x' = `r(p99)' if chw_p_`x' > `r(p99)' & chw_p_`x' != .
}

*** Generate time dummies
gen policy = 0 // captures the post-policy period (2014Q3 - 2018Q2)
replace policy = 1 if period_a >= 3

gen brexit = 0 // captures the post-referendum period (2016Q3 - 2018Q2)
replace brexit = 1 if period_a >= 5


*** Generate fixed effects:
egen region_time = group(region period_a)
egen region_time_const_FE = group(region_time dconstr)
egen region_time_lowinc_FE = group(region_time dlowinc)
egen county_time = group(county period_a)

*** REGRESSIONS:

* c.4
reghdfe chw_p_1 /*
*/ c.brexit##c.dconstr##c.dlowinc /*
*/ c.policy##c.dconstr##c.dlowinc /*
*/ if period_a >= 1 & period_a <= 6, /*
*/ absorb(region_time_const_FE region_time_lowinc_FE county_time lac) vce(cluster lac)
outreg2 using "LTI_T10A.tex", keep(c.brexit#c.dconstr#c.dlowinc c.policy#c.dconstr#c.dlowinc) nocons dec(3) tex

* c.5
reghdfe chw_p_3 /*
*/ c.brexit##c.dconstr##c.dlowinc /*
*/ c.policy##c.dconstr##c.dlowinc /*
*/ if period_a >= 1 & period_a <= 6, /*
*/ absorb(region_time_const_FE region_time_lowinc_FE county_time lac) vce(cluster lac)
outreg2 using "LTI_T10A.tex", keep(c.brexit#c.dconstr#c.dlowinc c.policy#c.dconstr#c.dlowinc) nocons dec(3) tex

restore

***** COLUMN 6: FINANCIAL CRISIS (PLACEBO) WITH REPEAT POSTCODE-TYPE *****

preserve

keep if columns == "6" // annual data with repeat postcode-house type index for the period 2004H2 - 2009H1

xtset lac period_a

*** Annual change in prices:
gen lp25 = log(price_p25)
bysort lac: gen c25 = lp25 - l.lp25


*** Windsorise:
gen c25w = c25
sum c25w, d
replace c25w = `r(p1)' if c25 < `r(p1)'
replace c25w = `r(p99)' if c25 > `r(p99)' & c25 != .

*** Generate time dummies:

gen fc = 0 // captures the crisis period (2007H2 - 2009H1)
replace fc = 1 if period_a >= 3

*** Generate fixed effects:
egen region_time = group(region period_a)
egen region_time_const_FE = group(region_time dconstr)
egen region_time_lowinc_FE = group(region_time dlowinc)
egen county_time = group(county period_a)

*** REGRESSIONS:

* c.6
reghdfe c25w /*
*/ c.fc##c.dconstr##c.dlowinc /*
*/ if period_a >= 1 & period_a <= 4, /*
*/ absorb(region_time_const_FE region_time_lowinc_FE county_time lac) vce(cluster lac)
outreg2 using "LTI_T10A.tex", keep(c.fc#c.dconstr#c.dlowinc) nocons dec(3) tex

restore

********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
